//
//  MinePageSystemCell.m
//  ShowYork
//
//  Created by hxh on 2020/8/25.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "MinePageSystemCell.h"

@interface MinePageSystemCell ()
@property (nonatomic,strong)UIImageView *icon;
@property (nonatomic,strong)UILabel *name;
@property (nonatomic,strong)UIView *line;
@end

@implementation MinePageSystemCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.icon = [[UIImageView alloc]init];
    [self.contentView addSubview:self.icon];
    
    self.name = [[UILabel alloc]init];
    self.name.text = @"xxxx";
    self.name.font = font(14);
    [self.contentView addSubview:self.name];
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.line];
    
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(30, 30)).priorityHigh();
        make.top.left.equalTo(self.contentView).offset(15);
        make.bottom.equalTo(self.contentView).offset(-15);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.icon);
        make.left.equalTo(self.icon.mas_right).offset(15);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(30);
        make.height.mas_equalTo(0.5);
    }];
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"MinePageSystemCell";
    MinePageSystemCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[MinePageSystemCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return cell;
}
- (void)setSystemIcon:(NSString *)icon title:(NSString *)title{
    [self.imageView setImage:[UIImage imageNamed:icon]];
    self.name.text = title;
}

@end
